<template>
    <view url="/pages/personalCenter/changeBind?number={{my_phone}}" @tap="jumpTo">
        <view class="accountSecurity">
            <view class="bind">
                <view class="bind_list">
                    <view>{{my_phone ? '绑定手机' : '未绑定手机'}}</view>
                    <text>{{my_phone}}</text>
                </view>
                <view class="genghuan">{{my_phone ? '更换手机' : '绑定手机'}} <i class="iconfont icon-jiantou"></i></view>
            </view>
        </view>
    </view>


</template>
<script>
    import wepy from 'wepy';
    import api from '@/api/api';
    import tip from '@/utils/tip';
    import {
        USER_INFO, USER_SPECICAL_INFO,USER_ID
    } from '@/utils/constant';

    export default class accountSecurity extends wepy.page {
        config = {  // 配置当前页面
            navigationBarTitleText: '账号与安全'    // 头部标题
        };
        components = {};

        data = {
            my_phone:''

        };

        async user_info() {
            let that = this;
            let user_id = wepy.getStorageSync(USER_ID) || '';
            api.getUserInformation({
              query:{}
            },user_id).then(function(res){
              if(res.data.code == 0){
                that.my_phone = res.data.data.phone;
                that.$apply();
              }else{
                tip.error(res.data.msg)
              }
            })
        }

        onLoad(){
            this.user_info();
        }

        methods = {  // 方法
            jumpTo(){
                let self = this;
                if (self.my_phone) {
                    wepy.navigateTo({
                        url: '/pages/personalCenter/changeBind?number='+self.my_phone
                    })
                } else {
                    wepy.navigateTo({
                        url: '/pages/personalCenter/wxBindPhone'
                    })
                }
            }
        };
        events = {};
    }

</script>
<style lang="less">
    .accountSecurity {
        .bind {
            background: #fff;
            border-top: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
            position: relative;
            margin-top: 20rpx;
            .bind_list {
                padding: 20rpx;
                padding-left: 40rpx;
                view {
                    color: #333;
                    padding-bottom: 10rpx;
                }
                text {
                    font-size: 28rpx;
                    color: #999;
                }
            }
            .genghuan {
                position: absolute;
                right: 30rpx;
                top: 30rpx;
                font-size: 28rpx;
                color: #999;
            }
        }
    }
</style>
